from queue import Queue
#Queue
import time
import threading
def get_detail_html(queue):
    '''爬取详情页'''
    while True:
        url=queue.get()#阻塞方法

        print('get detail html started',url)
        time.sleep(2)
        print('get detail html end')


def get_detail_url(queue):
    # global detail_url_list
    '''爬取文章列表'''
    while True:
        print('get detail url started')
        time.sleep(4)
        for i in range(20):
            queue.put(f'http://projectsedu.com/{i}')
        print('get detail url end')

if __name__ == '__main__':
    detail_url_list=Queue(maxsize=1000)
    thread_detail_url=threading.Thread(target=get_detail_url,args=(detail_url_list,))
    thread_detail_url.start()
    for i in range(10):
        html_thread=threading.Thread(target=get_detail_html,args=(detail_url_list,))
        html_thread.start()
